package tgipl3.expert.theBananaCrop;

import java.io.IOException;

public class UserMainCode
{
    //Assume following return types while writing the code for this question. 
    public static int output1 = 1;

    private static class Point {
    	int x, y;
    	public Point(int x, int y) {
    		this.x = x;
    		this.y = y;
    	}
    	public boolean equals(Object obj) {
    		if(obj instanceof Point)
    			return x == ((Point)obj).x && y == ((Point)obj).y;
    		return false;
    	}
    	public String toString() {
    		return "(" + x + ", " + y + ")";
    	}
    }
    
    public static void GetMaxDestroyed(String input1)
    {
        String[] in1 = input1.split(":");
        int rows = Integer.parseInt(in1[0]);
        int cols = Integer.parseInt(in1[1]);
        int numPts = Integer.parseInt(in1[2]);
        Point lPts[] = new Point[numPts];
        boolean bPts[][] = new boolean[rows][cols];
        in1[3] = in1[3].substring(1, in1[3].length() - 1);
        for(int i = 0, clind = 0; i < numPts; i++, clind += 2) {
        	in1[3] = in1[3].substring(clind);
        	clind = in1[3].indexOf('}');
        	String coords[] = in1[3].substring(1, clind).split(",");
        	int rowind = Integer.parseInt(coords[0]);
        	int colind = Integer.parseInt(coords[1]);
        	bPts[rowind - 1][colind - 1] = true;
        	lPts[i] = new Point(rowind, colind);
        }
        
        for(int i = 0; i < numPts; i++) {
        	jloop: for(int j = i + 1; j < numPts; j++) {
        		int dx = lPts[i].x - lPts[j].x, dy = lPts[i].y - lPts[j].y;
        		int nx = lPts[j].x - dx, ny = lPts[j].y - dy;
        		if(nx >= 1 && nx <= rows && ny >= 1 && ny <= cols)
        			continue;
        		int numLinePts = 1;
        		nx = lPts[i].x;
        		ny = lPts[i].y;
        		while(nx >= 1 && nx <= rows && ny >= 1 && ny <= cols) {
        			if(!bPts[nx - 1][ny - 1])
        				continue jloop;
        			numLinePts++;
        			nx += dx;
        			ny += dy;
       			}
        		if(numLinePts > output1)
        			output1 = numLinePts;
        	}
        }
    }
    
    public static void main(String[] args) throws IOException {
    	GetMaxDestroyed("6:7:14:{{2,1},{6,6},{4,2},{2,5},{2,6},{2,7},{3,4},{6,1},{6,2},{2,3},{6,3},{6,4},{6,5},{6,7}}");
    	System.out.println(output1);
    }
}